function $(id)
{
	return document.getElementById(id);
}

function init()
{
	loadLocalUpdates();
	
	initStyle();
	
	initSofkeys();
	
	widget.setNavigationEnabled(false);	
	
	createUI();
	
	searchFilter = loadFilters();
	
	applyFilters();
	
	createSettings();
}
function is5thEdition()
{
	return window.innerWidth > 320 && window.innerHeight > 320;
}
function initSofkeys()
{
	menu.showSoftkeys();
	
	var about = new MenuItem("About", 9001);
	about.onSelect = showAbout;
	menu.append(about);
	
	var settings = new MenuItem("Settings", 9002);
	settings.onSelect = showSettings;
	menu.append(settings);
}
function showAbout()
{
	$('screen_search').style.display = 'none';
	$('screen_about').style.display = '';
	$('screen_settings').style.display = 'none';
	
	menu.setRightSoftkeyLabel("Back", back);
}
function showSettings()
{
	$('screen_search').style.display = 'none';
	$('screen_about').style.display = 'none';
	$('screen_settings').style.display = '';
	
	menu.setRightSoftkeyLabel("Back", settingsBack);
}
function showSearch()
{
	$('screen_search').style.display = '';
	$('screen_about').style.display = 'none';
	$('screen_settings').style.display = 'none';
	
	menu.setRightSoftkeyLabel("Exit", exit);
}
function settingsBack()
{
	for(var i = 0; i < searchTypes.length; i++)
	{
		searchFilter[i] = $('media_check_' + i).checked ? 1 : 0;
		
		saveFilters(searchFilter);
	}
	
	applyFilters();
	
	showSearch();
}
function back()
{
	showSearch();
}
function exit()
{
	window.close();
}
function initStyle()
{
	document.styleSheets[0].disabled = !is5thEdition();
	document.styleSheets[1].disabled = is5thEdition();
	
	onResize();
}
function onResize()
{
	$('search_tabs').style.width = (window.innerWidth) + 'px';
	
	$('screen_container').style.height = (window.innerHeight - $('header').offsetHeight) + 'px';
}
